import Heap from '../09_堆结构Heap/06_堆结构Heap(二叉堆-即实现最大堆，又实现最小堆)'

// 2、创建PriorityQueue
class PriorityQueue<T> {
    private heap:Heap<T> = new Heap();

    enqueue(value:T){
        return this.heap.insert(value)
    }
    dequeue():T | undefined {
        return this.heap.extract();
    }
    peek(): T | undefined {
        return this.heap.peek();
    }

    isEmpty(){
        return this.heap.isEmpty();
    }
    size(){
        return this.heap.size();
    }
}

class Student {
    name: string;
    store: number;
    constructor(name:string,score:number){
        this.name = name;
        this.store = score;
    }
    valueOf(){
        return this.store;
    }
}

const pQueue = new PriorityQueue<Student>()
pQueue.enqueue(new Student('why',99))
pQueue.enqueue(new Student('kobe',89))
pQueue.enqueue(new Student('jams',95))
pQueue.enqueue(new Student('curry',88))

while(!pQueue.isEmpty()){
    console.log(pQueue.dequeue())
}




